# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=brutex
pkgver=114.eacd084
pkgrel=1
groups=('blackarch' 'blackarch-automation' 'blackarch-cracker')
pkgdesc='Automatically brute force all services running on a target.'
arch=('any')
url='https://github.com/1N3/BruteX'
license=('custom:unknown')
makedepends=('git')
depends=('bash' 'hydra' 'masscan' 'nmap' 'net-snmp' 'dnsenum')
source=("$pkgname::git+https://github.com/1N3/BruteX.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

package() {
  cd $pkgname

  _tools="brutex brutex-masscan"

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md

  rm README.md loot/README.md

  cp -a * "$pkgdir/usr/share/$pkgname/"

  for i in $_tools ; do
    cat > "$pkgdir/usr/bin/$i" << EOF
#!/bin/sh
cd /usr/share/$pkgname
exec bash $i "\$@"
EOF
    chmod +x "$pkgdir/usr/bin/$i"
  done
}

